﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Qplus.UI
{
    public partial class WaitControl : UserControl
    {
        public WaitControl()
        {
            InitializeComponent();
            _loop.Duration = TimeSpan.FromMilliseconds(10d);
            _loop.Completed += new EventHandler(_loop_Completed);
            _loop.Begin();
        }
        private int _currValue = 0;
        private Storyboard _loop = new Storyboard();
        void _loop_Completed(object sender, EventArgs e)
        {
            this.progressBar.Value = _currValue;
            this.progressTxt.Text = _currValue.ToString() + "%";
            //_currValue = _currValue > 100 ? 0 : ++_currValue;
            if (_currValue > 100)
            {
                this.CloseMeAsPopup();
            }
            else _currValue++;
            _loop.Begin();
        }
    }
}
